<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/all.conf.php');
require_once(__PHY_LIB.'/inc/page.inc.php');
require_once(__PHY_LIB.'/class/uDirector.class.php');
require_once(__PHY_LIB.'/class/uWork.class.php');

$rP = validate($_GET, 'pg:n');

/// 导演列表 ///
$rPager = array(
	'Sze' => 2,
	'Req' => 'pg',
	'Num' => max(1, $rP['pg']),
    'Bse' => http_build_query(array_slice($rP, 0, -1)),
);
$oList = new uDirectorList();
$rPager['Cnt'] = $oList->countAll();
$rPager['Max'] = ceil($rPager['Cnt']/$rPager['Sze']);
$oList->cfgOrder('id DESC');
$oList->load($rPager['Sze']*($rPager['Num'] - 1), $rPager['Sze']);
while ($oOne = $oList->nextItem()) {
	$oWork = new uWork($oOne->get('work_1_id'), 'title,tudou_link');
	$oOne->set('work_1_title', $oWork->get('title'));
	$oOne->set('work_1_tudou_id', $oWork->get('tudou_link'));
	$oWork = new uWork($oOne->get('work_2_id'), 'title,tudou_link');
	$oOne->set('work_2_title', $oWork->get('title'));
	$oOne->set('work_2_tudou_id', $oWork->get('tudou_link'));
	$oWork = new uWork($oOne->get('work_3_id'), 'title,tudou_link');
	$oOne->set('work_3_title', $oWork->get('title'));
	$oOne->set('work_3_tudou_id', $oWork->get('tudou_link'));
}
$oTpl->assign('rList', $oList->fetchArray());
$oTpl->assign('rPager', $rPager);

$oTpl->display(dirname(__FILE__).'/'.basename(__FILE__, '.php').'.tpl');
?>
